package com.demo0301.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/demo0301/demo04.do")
public class Demo04Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter writer = response.getWriter();
        //往网页当中打印请求信息
        writer.write("getMethod():" + request.getMethod() + "<br/>");
        writer.write("getRequestURI():" + request.getRequestURI() + "<br/>");
        writer.write("getRequestURL():" + request.getRequestURL() + "<br/>");
        writer.write("getQueryString():" + request.getQueryString() + "<br/>");
        writer.write("getProtocol():" + request.getProtocol() + "<br/>");
        writer.write("getContextPath():" + request.getContextPath() + "<br/>");
        writer.write("getPathInfo():" + request.getPathInfo() + "<br/>");
        writer.write("getPathTranslated():" + request.getPathTranslated() + "<br/>");
        writer.write("getServletPath():" + request.getServletPath() + "<br/>");
        writer.write("getRemoteAddr():" + request.getRemoteAddr() + "<br/>");
        writer.write("getRemoteHost():" + request.getRemoteHost() + "<br/>");
        writer.write("getRemotePort():" + request.getRemotePort() + "<br/>");
        writer.write("getLocalName():" + request.getLocalName() + "<br/>");
        writer.write("getLocalPort():" + request.getLocalPort() + "<br/>");
        writer.write("getServerName():" + request.getServerName() + "<br/>");
        writer.write("getServerPort():" + request.getServerPort() + "<br/>");
        writer.write("getScheme():" + request.getScheme() + "<br/>");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
